<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Banner extends CI_Model {
  
  var $table_name = 'banners';

  function addBanner($img_url, $url) {  
    $data = array('img_url' => $img_url, 'url' => $url);
    $this->db->insert($this->table_name, $data);
    $this->db->where($data);
    $res = $this->db->get($this->table_name);
    return $res->result();
  }

  function editBanner($id, $img_url, $url) {
    $data = array('img_url'=>$img_url);
    $this->db->where('id',$id);
    $this->db->set($data);
		$this->db->update($this->table_name);
  }

  function deleteBanner($id) {
    $this->db->delete($this->table_name, array('id' => $id));
  }

  function getBanners() {
    return $this->db->get($this->table_name)->result();
  }

}